<h1><%= @review_type.title%></h1>
<p id="notice"><%= notice %></p>
<%= link_to 'Create Review', new_review_type_review_path(@review_type) %>

<hr/>
<h2>Summary of <%= pluralize(@review_type.num_of_reviews,"Review") %></h2>

<TABLE>
  <tr>
    <td>
      <table title="The number of reviews broken down by overall rating.">
        <tr>
          <td colspan="2"><b>Number of Reviews</b><td>
        </tr>
        <% @review_type.overall_rating_criterion.rating_scale_elements.reverse.each do |rating_scale_element| %>
        <tr>
          <td >
              <%= rating_scale_element.name%>
          </td>
          <td align="right">
              <%= "%.0f" % (@review_type.overall_rating_criterion.get_num_of_ratings(rating_scale_element)) %>
          </td>
        </tr>
        <% end %>
      </table>
    </td>
    <td width="30px">
    <td valign="top">
      <table title="The average rating is a value between -100(Negative) and 100(Positive).">
        <tr>
          <td colspan="2"><b>Average Rating</b><td>
        </tr>
        <tr>
          <td>
              <%= @review_type.overall_rating_criterion.name%>
          </td>
          <td align="right">
              <%= "%.0f" % @review_type.overall_rating_criterion.avg_rating %>
          </td>
        </tr>
        <% @review_type.custom_rating_criterions.each do |rating_criterion| %>
        <tr>
          <td>
              <%= rating_criterion.name%>
          </td>
          <td align="right">
              <%= "%.0f" % rating_criterion.avg_rating %>
          </td>
        </tr>
        <% end %>
      </table>
    </td>
  </tr>
</TABLE>
<hr/>

<% @reviews.each do |review| %>
  <h2><%= review.title %></h2>
  <p><%= review.review_text %></p>
  <table>
    <tr>
      <td>
      <%= review.overall_rating.rating_criterion.name%>
      </td>
      <td>
        <% review.overall_rating.rating_criterion.rating_scale_elements.each do |rating_scale_element| %>
          <%= radio_button_tag("", rating_scale_element.value,rating_scale_element.value==review.overall_rating.rating_value, :disabled => true,:title=>rating_scale_element.fullname) %>
        <% end %>
      </td>
      <td>
        <%= review.overall_rating.rating_name %> 
      </td>
    </tr>
    <% review.custom_ratings.each do |rating| %>
    <tr>
      <td>
      <%= rating.rating_criterion.name%>
      </td>
      <td>
        <% rating.rating_criterion.rating_scale_elements.each do |rating_scale_element| %>
          <%= radio_button_tag("", rating_scale_element.value,rating_scale_element.value==rating.rating_value, :disabled => true,:title=>rating_scale_element.fullname) %>
        <% end %>
      </td>
      <td>
        <%= rating.rating_name %> 
      </td>
    </tr>
    <% end %>
  </table>
  <%= review.created_at.localtime.strftime("%Y-%m-%d %H:%M:%S")%>
  <hr/>
<% end %>